﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using cecbData;
using CECB.Project;
using CECB.Activity;
using CECB.Member;
using CECB.Impact;
using CECB.Dashbord;
using System.Timers;
using System.Threading.Tasks;
using System.Threading;
namespace CECB
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            
            listBoxRecentProjects.ItemsSource = new DSSEntities().Projects;
              
        }
        private  Boolean _isAdmin = false;
        private Members _loggedMem;
        
        public MainWindow(Boolean isadmin , Members mem)
        {
            InitializeComponent();
            _isAdmin = isadmin;
            listBoxRecentProjects.ItemsSource = new DSSEntities().Projects;
            _loggedMem = mem;
            checkForAdminFacilities(isadmin);
            textBlockLoggedUser.Text = mem.mem_name;
        }

        private Boolean checkForAdminFacilities(Boolean isadmin) {

            if (isadmin) return true;
            else return false;
        }

         

        private void canvas1_MouseEnter(object sender, MouseEventArgs e)
        {
            Canvas c = (Canvas)sender;
            DoubleAnimation s = new DoubleAnimation(1, TimeSpan.FromSeconds(1));
            c.BeginAnimation(Canvas.OpacityProperty, s);
        }

        private void canvas1_MouseLeave(object sender, MouseEventArgs e)
        {
            Canvas c = (Canvas)sender;
            DoubleAnimation s = new DoubleAnimation(0, TimeSpan.FromSeconds(1));
            c.BeginAnimation(Canvas.OpacityProperty, s);
        }
         
        private void button_searchClick(object sender, RoutedEventArgs e)
        {
            new DashSlider_Window().Show();
        }

        private void buttonNotification_Click(object sender, RoutedEventArgs e)
        {
            new Email.EmailReader_Window().Show();
        }
 

        private void buttonExit_Click(object sender, RoutedEventArgs e)
        {
            App.Current.Shutdown();
        }
         

        private void buttonSendEmail_Click(object sender, RoutedEventArgs e)
        {
            new ActivationCodeEmail_Window().Show();
        }
         
        private void buttonSearchProjects_Click(object sender, RoutedEventArgs e)
        {
            new Team_Window().Show();
        }
          
        private void Button12_Click(object sender, RoutedEventArgs e)
        {
            new Project_Activity_Update_Window().Show();
        }
          
        private void StackPanel_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {

            if (checkForAdminFacilities(_isAdmin))
            {
                new FillMatrix_Window().ShowDialog();
            }
            else
            {
                MessageBox.Show("Access Denied!", "Message", MessageBoxButton.OK, MessageBoxImage.Error);
            }

        }

        private void StackPanel_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
        {
             
            if (checkForAdminFacilities(_isAdmin))
            {
                new Matrix.PendingMatrixValues_Window().ShowDialog();
            }
            else 
            {
                MessageBox.Show("Access Denied!", "Message", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }

        private void StackPanel_MouseLeftButtonDown_2(object sender, MouseButtonEventArgs e)
        {
            new SimpleMatrixCalculation().ShowDialog();
        }

        private void StackPanel_MouseLeftButtonDown_3(object sender, MouseButtonEventArgs e)
        {
            
            new Activity.ProjectActivityInsert_Window().ShowDialog();
        }

        private void StackPanel_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            new ProjectImpactsUpdate_Window().ShowDialog();
        }
         

        private void StackPanel_MouseLeftButtonDown_4(object sender, MouseButtonEventArgs e)
        {
            new ActivationCodeEmail_Window().ShowDialog();
        }

        private void StackPanel_MouseLeftButtonDown_5(object sender, MouseButtonEventArgs e)
        {
             
            expander1.IsExpanded = false;
        }

        private void StackPanel_MouseLeftButtonDown_6(object sender, MouseButtonEventArgs e)
        {
            new Impact.ProjectImpactInsert_Window().ShowDialog();
        }

        private void buttonSettings_Click(object sender, RoutedEventArgs e)
        {
            if (checkForAdminFacilities(_isAdmin))
            {
                new DashSlideSettings_Window().ShowDialog();
            }
            else
            {
                MessageBox.Show("Access Denied!", "Message", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            
        }
 
        private void StackPanel_MouseLeftButtonDown_7(object sender, MouseButtonEventArgs e)
        {
            new AddNewProject_Window().ShowDialog();
        }
         
        private void StackPanel_MouseLeftButtonDown_8(object sender, MouseButtonEventArgs e)
        {
             
            if (expanderTeam.IsExpanded)
                expanderTeam.IsExpanded = false;

            if (expander1.IsExpanded)
                expander1.IsExpanded = false;
            else
                expander1.IsExpanded = true;
        }
         
        private void StackPanel_PreviewMouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
        {
            new ViewFild_MatrixDetails().ShowDialog();
        }

        private void StackPanel_MouseLeftButtonDown_9(object sender, MouseButtonEventArgs e)
        {
            
            if (expanderProject.IsExpanded)
            {
                expanderProject.IsExpanded = false;
            }
            else
                expanderProject.IsExpanded = true;
           
        }

        private void StackPanel_MouseLeftButtonDown_10(object sender, MouseButtonEventArgs e)
        {
            new Project_Activity_Update_Window().ShowDialog();
        }

        private void StackPanel_MouseLeftButtonDown_11(object sender, MouseButtonEventArgs e)
        {
            
            new Insert_ProjEIADetails().ShowDialog();
        }
         
        private void GroupBox_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            new V_MemberUpdate_Window().ShowDialog();
        }

        private void GroupBox_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
        {
           
            if (expander1.IsExpanded)
                expander1.IsExpanded = false;


            if (expanderTeam.IsExpanded)
                expanderTeam.IsExpanded = false;
            else
                expanderTeam.IsExpanded = true;
        }
         
        private void GroupBox_MouseLeftButtonDown_2(object sender, MouseButtonEventArgs e)
        {
            new UpdateProj_BasicDtails().ShowDialog();
            
        }

        private void GroupBox_MouseLeftButtonDown_3(object sender, MouseButtonEventArgs e)
        {
            new UpdateProj_EIADetails().ShowDialog();
        }

        private void TextBlock_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            (FindResource("openc") as Storyboard).Begin(this);
        }

        private void GroupBox_MouseLeftButtonDown_4(object sender, MouseButtonEventArgs e)
        {
            new UpdateProj_EIADetails().ShowDialog();
          
        }

        private void grid1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
 
           new TemplateViwer_Window().ShowDialog();
        }
         
        private void GroupBox_MouseLeftButtonDown_5(object sender, MouseButtonEventArgs e)
        {
            new V_MemberNew_Window().ShowDialog();
        }

        private void GroupBox_MouseLeftButtonDown_6(object sender, MouseButtonEventArgs e)
        {
            new Team.Team_Search_Window().ShowDialog();
        }

        private void Image_MouseLeftButtonDown_1(object sender, MouseButtonEventArgs e)
        {
            this.WindowState = System.Windows.WindowState.Minimized;
        }

        private void GroupBox_MouseLeftButtonDown_7(object sender, MouseButtonEventArgs e)
        {
            new Team_Window().ShowDialog();
        }
         
        private void GroupBox_MouseLeftButtonDown_9(object sender, MouseButtonEventArgs e)
        {
            new Member.V_MemberSearch_Window().ShowDialog();
        }

        private void TextBlock_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            new Login_Window_New().Show();
            this.Close();
        }

        private void GroupBox_MouseLeftButtonDown_8(object sender, MouseButtonEventArgs e)
        {
            new LeopoldMetrixCharts.check_Window1().ShowDialog();

        }

        private void GroupBox_MouseLeftButtonDown_10(object sender, MouseButtonEventArgs e)
        {
            new Impact.ProjectImpactsUpdate_Window().ShowDialog();
        }
         
    }
}
